<?php

namespace App\Http\Controllers\Api\V1;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redis;
use Illuminate\Support\Facades\Cache;
use App\Http\Controllers\Api\Controller;
use App\Handles\WechatHandle;
use App\Models\User;
use App\Models\DistributionBgposter;
use App\Models\Qrcode;

class UserController extends Controller
{

    /**
     * @return json 用户信息
     */
    public function detail(Request $request)
    {
        return $this->success($request->userInfo);
    }

    /**
     * @return string 商城默认海报信息
     */
    public function posterBg(Request $request, DistributionBgposter $distributionBgposter)
    {
        $bg_poster = $distributionBgposter->where('PAGE_ID', '=', 'defaultid')->first();
        return $this->success($bg_poster);
    }

    /**
     * 取出员工可跳转到商家主页的二维码携带员工信息
     * @return json 
     */
    public function posterUser(Request $request, Qrcode $qrcode)
    {
        $auth = auth('api')->user();
        $qrcode =  $qrcode->where('BRANCH_GUID', '=', $auth->EMPLOYEESUPBRANCHGUID)->first();
        return $this->success($qrcode);
    }
}
